using UnityEngine;
using QFramework;

namespace Survivor
{
	public partial class Bomb : ViewController
	{
		private void OnTriggerEnter2D(Collider2D other)
		{
			if (other.GetComponent<CollectableArea>())
			{
				AudioKit.PlaySound("Bomb");
				CameraCrontroller.PlayShake();
				gameObject.DestroySelfGracefully();
				var enemyGameObjs = GameObject.FindGameObjectsWithTag("Enemy");
				foreach (var enemyGameObj in enemyGameObjs)
				{
					if (enemyGameObj.activeSelf == false)
						continue;					
					var enemy = enemyGameObj.GetComponent<Enemy>();
					if (enemy == null)
						continue;
					enemy.Hurt(enemy.Hp);
				}
			}
		}
	}
}
